﻿using MediatR;
using WMS.API.Application.Command.InventoryManagement;
using WMS.Domain.Entities.InventoryManagement;
using WMS.Domain.Entities.StocktakingManagement;
using WMS.ErrorCode;
using WMS.Interfactructure.Interfaces;

namespace WMS.API.Application.CommandHandlers.InventoryManagement
{
    public class QueryBoxCommandHandler : IRequestHandler<QueryBoxCommand, APIResult<List<BoxManagement>>>
    {
        private readonly IBaseRepository<BoxManagement> _boxbaseRepository;
        public QueryBoxCommandHandler(IBaseRepository<BoxManagement> boxbaseRepository)
        {
            _boxbaseRepository = boxbaseRepository;
        }

        public Task<APIResult<List<BoxManagement>>> Handle(QueryBoxCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<BoxManagement>> result = new APIResult<List<BoxManagement>>("查询箱子型号成功");
            result.Code = ResultCode.Success;

            var list = _boxbaseRepository.GetAll();

          
            result.Data = list.ToList();

            return Task.FromResult(result);
        }
    }
}
